import { post, get } from "@/api/axios"
import type { BiuJsonResult } from "../biu-json-result"
import { TEXT_PLAIN } from "@/api/content-type"

const urlPrefix: string = "/api/server-management"

export interface Server {
  id: string
  name: string
  proxyServer: {
    host: string
    port: number
  }
  ping: number
  accessTime: string
}

export function doAccess(url: string) {
  return post<BiuJsonResult<boolean>>(urlPrefix + "/access", url, TEXT_PLAIN)
}

export function doQueryServerNode() {
  return get<BiuJsonResult<Array<Server>>>(urlPrefix + "/query")
}

export function doDeleteServerNode(id: string) {
  return post<BiuJsonResult<boolean>>(urlPrefix + "/delete?id=" + id)
}
